package com.tgky.ybzb.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.tgky.ybzb.common.Result;
import com.tgky.ybzb.entity.ZstpType;
import com.tgky.ybzb.service.ZstpTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 知识图谱类型表（树表）(ZstpType)表控制层
 *
 * @author makejava
 * @since 2024-09-06 10:25:14
 */
@RestController
@AllArgsConstructor
@Slf4j
@Api(value = "知识类型表", tags = "知识类型页面接口")
@RequestMapping("zstpType")
public class ZstpTypeController {
    /**
     * 服务对象
     */
    @Resource
    private ZstpTypeService zstpTypeService;

    /**
     * 分页查询所有数据
     *
     * @param zstpType 查询实体
     * @return 所有数据
     */
    @PostMapping("/list")
    @ApiOperationSupport(order = 0)
    @ApiOperation(value = "树形列表接口")
    public Result selectAllList(@RequestBody ZstpType zstpType) {
        return Result.successData(zstpTypeService.selectAllList(zstpType));
    }


    /**
     * 新增数据
     *
     * @param zstpType 实体对象
     * @return 新增结果
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "保存知识类型")
    public Result insert(@RequestBody ZstpType zstpType) {
        zstpTypeService.save(zstpType);
        return Result.success("保存成功");
    }

    /**
     * 修改数据
     *
     * @param zstpType 实体对象
     * @return 修改结果
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "更新知识类型")
    public Result update(@RequestBody ZstpType zstpType) {
        zstpTypeService.updateById(zstpType);
        return Result.success("更新成功");
    }

    /**
     * 删除数据
     *
     * @param
     * @return 删除结果
     */
    @PostMapping("/delete")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "删除知识类型")
    public Result delete(@RequestBody ZstpType zstpType) {
        zstpTypeService.removeById(zstpType);
        return Result.success("删除成功");
    }
}

